package com.block.datapush.service.apipush.utils;

import com.alibaba.fastjson.JSONArray;

import java.util.HashSet;
import java.util.Set;

public class MobileMd5IsInListUtils {

    public static boolean isMobileMd5InList(JSONArray md5List, String mobileMd5) {
        if (md5List == null || mobileMd5 == null) {
            return false;
        }
        Set<String> md5Set = new HashSet<>();
        // 遍历 JSON 数组，处理嵌套数组的情况
        for (Object item : md5List) {
            if (item instanceof JSONArray) {
                JSONArray innerArray = (JSONArray) item;
                md5Set.addAll(innerArray.toJavaList(String.class));
            } else if (item instanceof String) {
                md5Set.add((String) item);
            }
        }
        return md5Set.contains(mobileMd5);
    }
}
